package com.longge.wechat.socket;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TestServer {
	public static void main(String[] args) {
		OutputStream os = null;
		InputStream is = null;
		try {
			ServerSocket ss = new ServerSocket(6666);
			Socket s = ss.accept();
			is = s.getInputStream();
			os = s.getOutputStream();
			DataInputStream dis = new DataInputStream(is);
			DataOutputStream dos = new DataOutputStream(os);
			String str = null;
			if((str = dis.readUTF()) != null) {
				System.out.println("内容是："+str+"[from:"+s.getInetAddress()+"---port:"+s.getPort()+"]");
			}
			dos.writeUTF("你好，已收到");
			dis.close();
			dos.close();
			s.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
